/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package communication.impl;

import communication.Client;
import communication.CommunicationDiagram;
import communication.CommunicationPackage;
import communication.Server;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Diagram</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link communication.impl.CommunicationDiagramImpl#getContainsServers <em>Contains Servers</em>}</li>
 *   <li>{@link communication.impl.CommunicationDiagramImpl#getContainsClients <em>Contains Clients</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CommunicationDiagramImpl extends EObjectImpl implements CommunicationDiagram {
	/**
	 * The cached value of the '{@link #getContainsServers() <em>Contains Servers</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getContainsServers()
	 * @generated
	 * @ordered
	 */
	protected EList<Server> containsServers;

	/**
	 * The cached value of the '{@link #getContainsClients() <em>Contains Clients</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getContainsClients()
	 * @generated
	 * @ordered
	 */
	protected EList<Client> containsClients;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CommunicationDiagramImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CommunicationPackage.Literals.COMMUNICATION_DIAGRAM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Server> getContainsServers() {
		if (containsServers == null) {
			containsServers = new EObjectContainmentEList<Server>(Server.class, this, CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_SERVERS);
		}
		return containsServers;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Client> getContainsClients() {
		if (containsClients == null) {
			containsClients = new EObjectContainmentEList<Client>(Client.class, this, CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_CLIENTS);
		}
		return containsClients;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_SERVERS:
				return ((InternalEList<?>)getContainsServers()).basicRemove(otherEnd, msgs);
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_CLIENTS:
				return ((InternalEList<?>)getContainsClients()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_SERVERS:
				return getContainsServers();
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_CLIENTS:
				return getContainsClients();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_SERVERS:
				getContainsServers().clear();
				getContainsServers().addAll((Collection<? extends Server>)newValue);
				return;
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_CLIENTS:
				getContainsClients().clear();
				getContainsClients().addAll((Collection<? extends Client>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_SERVERS:
				getContainsServers().clear();
				return;
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_CLIENTS:
				getContainsClients().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_SERVERS:
				return containsServers != null && !containsServers.isEmpty();
			case CommunicationPackage.COMMUNICATION_DIAGRAM__CONTAINS_CLIENTS:
				return containsClients != null && !containsClients.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //CommunicationDiagramImpl
